package com.gpzx.zx.module.home.ui.adapter

import android.content.Context
import android.text.TextUtils
import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.gpzx.zx.databinding.*
import com.gpzx.zx.module.home.frame.model.OrgInfo
import com.wkq.database.dao.NewsComment
import com.wkq.lib_base.adapter.KtDataBindingAdapter
import com.wkq.lib_base.adapter.KtDataBindingViewHolder

/**
 *
 * 作者:吴奎庆
 *
 * 时间:2020/6/8
 *
 * 用途:
 */


class NewsCommentAdapter(context: Context, layoutId: Int) : KtDataBindingAdapter<NewsComment>(context, layoutId) {

    override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
        super.onBindViewHolder(holder, position)
        var bindingHolder = holder as KtDataBindingViewHolder
        var binding = bindingHolder.viewBinding as ItemNewsCommnentBinding
        binding.data = getItem(position)

        if (TextUtils.isEmpty(getItem(position)!!.news_icon)) {
            binding.ivIcon.visibility = View.GONE
        } else {
            Glide.with(mContext).load(getItem(position)!!.news_icon).into(binding.ivIcon)
            binding.ivIcon.visibility = View.VISIBLE
        }

        if (viewClickListener != null) {
            binding.root.setOnClickListener {
                viewClickListener?.onViewClick(binding.root, getItem(position))
            }
        }

    }

}